package com.ruoyi.web.controller.erpbase;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.SendoutCompany;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ReceiveCompany;
import com.ruoyi.system.service.IReceiveCompanyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户信息Controller
 * 
 * @author he
 * @date 2025-08-13
 */
@Api(tags = "客户接口")
@RestController
@RequestMapping("/system/receiveCompany")
public class ReceiveCompanyController extends BaseController
{
    @Autowired
    private IReceiveCompanyService receiveCompanyService;

    /**
     * 查询客户信息列表
     */
    @ApiOperation("查询客户信息")
    @PreAuthorize("@ss.hasPermi('system:receiveCompany:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReceiveCompany receiveCompany)
    {
        startPage();
        List<ReceiveCompany> list = receiveCompanyService.selectReceiveCompanyList(receiveCompany);
        return getDataTable(list);
    }

    @ApiOperation("查询客户下拉框信息")
    @PostMapping("/getReceiveCompanyInfoList")
    public TableDataInfo getReceiveCompanyInfoList(@RequestParam(value = "paramName", required = false) String paramName)
    {
        List<ReceiveCompany> list = receiveCompanyService.getReceiveCompanyInfoList(paramName);
        return getDataTable(list);
    }

    /**
     * 导出客户信息列表
     */
    @ApiOperation("导出客户信息")
    @PreAuthorize("@ss.hasPermi('system:receiveCompany:export')")
    @Log(title = "客户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReceiveCompany receiveCompany)
    {
        List<ReceiveCompany> list = receiveCompanyService.selectReceiveCompanyList(receiveCompany);
        ExcelUtil<ReceiveCompany> util = new ExcelUtil<ReceiveCompany>(ReceiveCompany.class);
        util.exportExcel(response, list, "客户信息数据");
    }

    /**
     * 获取客户信息详细信息
     */
    @ApiOperation("查询客户详细信息")
    @PreAuthorize("@ss.hasPermi('system:receiveCompany:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(receiveCompanyService.selectReceiveCompanyById(id));
    }

    /**
     * 新增客户信息
     */
    @ApiOperation("新增客户信息")
    @PreAuthorize("@ss.hasPermi('system:receiveCompany:add')")
    @Log(title = "客户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReceiveCompany receiveCompany)
    {
        return toAjax(receiveCompanyService.insertReceiveCompany(receiveCompany));
    }

    /**
     * 修改客户信息
     */
    @ApiOperation("修改客户信息")
    @PreAuthorize("@ss.hasPermi('system:receiveCompany:edit')")
    @Log(title = "客户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReceiveCompany receiveCompany)
    {
        return toAjax(receiveCompanyService.updateReceiveCompany(receiveCompany));
    }

    /**
     * 删除客户信息
     */
    @ApiOperation("删除客户信息")
    @PreAuthorize("@ss.hasPermi('system:receiveCompany:remove')")
    @Log(title = "客户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(receiveCompanyService.deleteReceiveCompanyByIds(ids));
    }
}
